const mysql = require (`mysql`);
const dbConfig = require (`../config/dbconfig.js`)
const connection = mysql.createConnection(dbConfig);

connection.connect(function (err) {
    if (err) {
        throw err;
    }
    // console.log('connect mysql success');
});



//婆罗蜜撕

function dbQuery(sql) {
    return new Promise((resolve, reject) => {
        connection.query(sql, (err, result) => {
            if (err) {
                reject(err)
            }
            resolve(result)
        });

    })

}




//暴露模块
module.exports = dbQuery;